package online.flowerinsnow.minecraft.bukkit.manhunt.listener;

import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import online.flowerinsnow.minecraft.bukkit.manhunt.Manhunt;
import online.flowerinsnow.minecraft.bukkit.manhunt.util.StateUtils;

public class StateListener implements Listener {
    @EventHandler
    public void onJoin(PlayerJoinEvent e) {
        StateUtils.clearInventory(e.getPlayer());
        //noinspection ConstantConditions
        e.getPlayer().teleport(Bukkit.getWorld("world").getSpawnLocation());
        Manhunt.getScoreboardManager().initPlayerScoreboard(e.getPlayer());
        Manhunt.getBossBarManager().initPlayerBossBar(e.getPlayer());
    }
    @EventHandler
    public void onQuit(PlayerQuitEvent e) {
        StateUtils.clearAllState(e.getPlayer());
    }
}
